﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace UDPClient1
{
    class Program
    {
        static void Main(string[] args)
        {
            var sendBytes = Encoding.UTF8.GetBytes("服务器已收到");
            UdpClient udpReceive = new UdpClient(11000);
            IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);

            byte[] receiveBytes = udpReceive.Receive(ref remoteIpEndPoint);
            string returnData = Encoding.ASCII.GetString(receiveBytes);
            udpReceive.Send(sendBytes, sendBytes.Length, remoteIpEndPoint);
            Console.WriteLine(remoteIpEndPoint.Address+":" + remoteIpEndPoint.Port +"   " + returnData.ToString());
            udpReceive.Close();
            Console.ReadKey();
        }
    }
}
